import vue from "vue";
import Mint from 'mint-ui';
import store from "./store"
import router from "./router/router"
import app from "./app"
import Plugin from "./util/Plugin"
import local from './util/local'
import imgPreview from './components/imgPreview'
vue.use(imgPreview)
import VueResource from 'vue-resource'
vue.use(VueResource);
import './style/reset'
import './font/iconfont.css'
import './style/app'
var VueTouch = require('vue-touch')
vue.use(VueTouch, {name: 'v-touch'})
import 'mint-ui/lib/style.css'
import registerFilters from "./util/filters"

vue.config.productionTip = false
vue.http.interceptors.push(function(request, next)  {
	let TOKEN=local.get('token')
	if(TOKEN){
		request.headers.set('authorization','bearer'+TOKEN);
	}
	next(function(response)  {
		return response
	});
});

// vue.use(MuseUI);
vue.use(Mint);
vue.use(Plugin);

/*
* 设置rem
* */
(function (doc, win) {
	var docEl = doc.documentElement,
		resizeEvt = 'orientationchange' in window ? 'orientationchange' : 'resize',
		recalc = function () {
			var clientWidth = docEl.clientWidth;
			if (!clientWidth) return;
			if(clientWidth>=640){
				docEl.style.fontSize = '100px';
			}else{
				docEl.style.fontSize = 100 * (clientWidth / 750) + 'px';
			}
		};

	if (!doc.addEventListener) return;
	win.addEventListener(resizeEvt, recalc, false);
	doc.addEventListener('DOMContentLoaded', recalc, false);
})(document, window);

//获取登录信息
store.commit("getLocalData")
registerFilters(vue)
//挂载
new vue({
	el:"#app",
    router:router,
	store,
	render:(h) => h(app)
})